
import { locations } from "../../../gpu/locations";
const SkyboxMaterial =/*wgsl*/`
override GAMM:f32=1.8;  

    struct Output {
      @location(0) color:vec4<f32>,
      #if ~{def.gBuffer}
        @location(1) worldPos:vec4<f32>,
        @location(2) worldNormal:vec4<f32>,
        #if ~{def.enablePick}
         @location(3) pickColor:vec4<f32>,
        #endif
      #else
        #if ~{def.enablePick}
          @location(1) pickColor:vec4<f32>,
        #endif
      #endif
    };
    struct Input {
      @location(0) localPos:vec3<f32>,
    };
    @group(${locations.map[0]}) @binding(${locations.map[1]}) var environmentMap: texture_cube<f32>;
    @group(${locations.mapSampler[0]}) @binding(${locations.mapSampler[1]}) var environmentMap_sampler:sampler;
    @group(${locations.enableDarker[0]}) @binding(${locations.enableDarker[1]}) var<uniform> enableDarker:f32;
    #if ~{def.environmenIntensity}
    @group(${locations.environmenIntensity[0]}) @binding(${locations.environmenIntensity[1]}) var<uniform> environmenIntensity: f32;
    #endif 
 
    @fragment
    fn main(input:Input) -> Output {
      var output:Output;
      if(enableDarker==1.0){
        output.color=vec4(0,0,0,1);
        #if ~{def.enablePick}
        output.pickColor=vec4(0,0,0,1);
        #endif
        #if ~{def.gBuffer}
          output.worldPos = vec4<f32>(input.localPos,-1.0);
          output.worldNormal = vec4<f32>(0,0,0,0);
        #endif
        return output;
      }
      #if ~{def.environmenIntensity}
      var envColor:vec3<f32> = textureSample(environmentMap,environmentMap_sampler,input.localPos).rgb*environmenIntensity;
      #else
      var envColor:vec3<f32> = textureSample(environmentMap,environmentMap_sampler,input.localPos).rgb;
      #endif 
      // envColor = vec3(1.0) - exp(-envColor * 1.0);
      // envColor = pow(envColor, vec3(1.0/2.2));
      let kk=GAMM;
      output.color=vec4(envColor, 1.0);
      #if ~{def.enablePick}
        output.pickColor=vec4(0,0,0,1);
      #endif
      #if ~{def.gBuffer}
        output.worldPos = vec4<f32>(input.localPos,-1.0);
        output.worldNormal = vec4<f32>(0,0,0,0);
      #endif
      return output;
    }`
export { SkyboxMaterial }